#include "centralwidget.h"
#include <QApplication>

CentralWidget::CentralWidget(QWidget *parent) :
    QWidget(parent)
{
    setObjectName(QString::fromUtf8("QWayCentralWidget"));
    verticalLayout = new QVBoxLayout(this);
    verticalLayout->setSpacing(1);
    verticalLayout->setContentsMargins(1, 1, 1, 1);
    verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    mapCtx = new Context(Point(55.7, 37.8), QSize(480, 640), this);
    mapView = new QGraphicsView(mapCtx->scene(), this);
    mapView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    mapView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    mapView->setObjectName(QString::fromUtf8("mapView"));

    verticalLayout->addWidget(mapView);

    antialiasingCheckbox = new QCheckBox("antialiasing", this);
    antialiasingCheckbox->setChecked(mapCtx->getOptions().antialising);
    buildingCheckbox = new QCheckBox("show buildnings", this);
    buildingCheckbox->setChecked(mapCtx->getOptions().mapDetalization & MapElement::BUILDING);
    wayCheckbox = new QCheckBox("show ways", this);
    wayCheckbox->setChecked(mapCtx->getOptions().mapDetalization & MapElement::WAY);

    verticalLayout->addWidget(antialiasingCheckbox);
    verticalLayout->addWidget(buildingCheckbox);
    verticalLayout->addWidget(wayCheckbox);

    connect(antialiasingCheckbox, SIGNAL(stateChanged(int)), mapCtx, SLOT(updateAntialiasing(int)));
    connect(buildingCheckbox, SIGNAL(stateChanged(int)), mapCtx, SLOT(updateBuildingShow(int)));
    connect(wayCheckbox, SIGNAL(stateChanged(int)), mapCtx, SLOT(updateWayShow(int)));
    retranslateUi();
}

CentralWidget::~CentralWidget()
{
    delete mapView;
    delete verticalLayout;
    delete mapCtx;
}

void CentralWidget::retranslateUi()
{
    this->parentWidget()->setWindowTitle(QApplication::translate("MainWindow", "QWay", 0, QApplication::UnicodeUTF8));
} // retranslateUi

void CentralWidget::fitContext()
{
    mapCtx->resize(mapView->viewport()->geometry().size());
}
